home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / powerd / source / lib / chunky_lib.lha / Chunky / CopyChunkyBright.ass < prev    next >
Encoding:
Text File  |  2000-08-03  |  2.1 KB  |  96 lines

  1. ; this function writes a coloured pixel into the chunky buffer and returns
  2. ; colour of pixel that was in these coords originaly
  3.  
  4. ; CopyChunkyBright(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5)
  5.  
  6.     machine    mc68020
  7.  
  8.     xdef    _CopyChunkyBright
  9. _CopyChunkyBright
  10.     movem.l    d2-d7/a2-a3,-(a7)
  11.  
  12. ; DESTINATION BOUNDS
  13.     tst.l    d0        ; left bound
  14.     bge.s    .leftdone
  15.     move.l    d0,d7            ; store left negative offset
  16.     neg.l    d7
  17.     cmp.l    d4,d7
  18.     bge.s    .finish            ; out of bounds
  19.     moveq    #0,d0            ; left position
  20.     add.l    d7,d2
  21.     sub.l    d7,d4            ; new width
  22. .leftdone
  23.     tst.l    d1        ; top bound
  24.     bge.s    .topdone
  25.     move.l    d1,d7            ; store top negative offset
  26.     neg.l    d7
  27.     cmp.l    d5,d7
  28.     bge.s    .finish            ; out of bounds
  29.     moveq    #0,d1            ; top position
  30.     add.l    d7,d3
  31.     sub.l    d7,d5            ; new height
  32. .topdone
  33.     cmp.l    (a0),d0        ; right bound
  34.     bgt.s    .finish
  35.     move.l    (a0),d7            ; store maximal width
  36.     sub.l    d0,d7            ; change width
  37.     cmp.l    d4,d7            ; check if we can fit
  38.     bgt.s    .rightdone        ; we can fit
  39.     move.l    d7,d4            ; new width, we can't fit
  40. .rightdone
  41.     cmp.l    (4,a0),d1        ; bottom bound
  42.     bgt.s    .finish
  43.     move.l    (4,a0),d7            ; store maximal width
  44.     sub.l    d1,d7            ; change width
  45.     cmp.l    d5,d7            ; check if we can fit
  46.     bgt.s    .bottomdone        ; we can fit
  47.     move.l    d7,d5            ; new width, we can't fit
  48. .bottomdone
  49.  
  50.     move.l    (a0),d6        ; get dest width to d6
  51.     muls.l    d1,d6
  52.     add.l    d6,d0        ; now we have start position in dest buffer
  53.     move.l    (8,a0),a2
  54.     add.l    d0,a2
  55.  
  56.     move.l    (a1),d6
  57.     muls.l    d3,d6
  58.     add.l    d6,d2
  59.     move.l    (8,a1),a3
  60.     add.l    d2,a3        ; and start position in source buffer
  61.  
  62.     move.l    (a0),d2        ; get the d2 and d3 values
  63.     sub.l    d4,d2
  64.     move.l    (a1),d3
  65.     sub.l    d4,d3
  66.  
  67.     subq.l    #1,d4
  68.     subq.l    #1,d5
  69.     move.l    d4,d6        ; store width
  70. .loopy    move.l    d6,d4        ; restore width
  71. .loopx    move.b    (a3)+,d0        ; get brightness
  72.     move.b    (a2),d1        ; get destination colour
  73.     move.l    d1,d7
  74.     andi.b    #%11110000,d7    ; store colour level
  75.     andi.b    #%00001111,d1    ; get colour index
  76.     subq.b    #8,d0        ; get central value
  77.     add.b    d0,d1
  78.     tst.b    d1
  79.     ble.s    .zero
  80.     cmp.b    #15,d1
  81.     bge.s    .max
  82.     move.b    d1,d0
  83.     or.b    d7,d0
  84.     bra.s    .goon
  85. .max    moveq    #15,d0
  86.     or.b    d7,d0
  87.     bra.s    .goon
  88. .zero    move.l    d7,d0
  89. .goon    move.b    d0,(a2)+        ; copy pixel
  90.     dbra.s    d4,.loopx
  91.     adda.l    d2,a2
  92.     adda.l    d3,a3
  93.     dbra.s    d5,.loopy
  94. .finish    movem.l    (a7)+,d2-d7/a2-a3
  95.     rts
  96.